Skip to contentMethod: addAll(int, Collection)
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.proxy.lazy;
19:
20: import cz.cvut.kbss.jopa.model.metamodel.CollectionType;
21: import cz.cvut.kbss.jopa.model.metamodel.FieldSpecification;
22: import cz.cvut.kbss.jopa.sessions.UnitOfWork;
23: import cz.cvut.kbss.jopa.utils.CollectionFactory;
24:
25: import java.util.Collection;
26: import java.util.List;
27: import java.util.ListIterator;
28:
29: public class LazyLoadingListProxy<O, E> extends LazyLoadingCollectionProxy<O, List<E>, E> implements List<E> {
30:
31: public LazyLoadingListProxy(O owner, FieldSpecification<? super O, List<E>> fieldSpec,
32: UnitOfWork persistenceContext) {
33: super(owner, fieldSpec, persistenceContext);
34: }
35:
36: @Override
37: public List<E> unwrap() {
38: return (List<E>) CollectionFactory.createDefaultCollection(CollectionType.LIST);
39: }
40:
41: @Override
42: public boolean addAll(int index, Collection<? extends E> c) {
43: return triggerLazyLoading().addAll(index, c);
44: }
45:
46: @Override
47: public E get(int index) {
48: return triggerLazyLoading().get(index);
49: }
50:
51: @Override
52: public E set(int index, E element) {
53: return triggerLazyLoading().set(index, element);
54: }
55:
56: @Override
57: public void add(int index, E element) {
58: triggerLazyLoading().add(index, element);
59: }
60:
61: @Override
62: public E remove(int index) {
63: return triggerLazyLoading().remove(index);
64: }
65:
66: @Override
67: public int indexOf(Object o) {
68: return triggerLazyLoading().indexOf(o);
69: }
70:
71: @Override
72: public int lastIndexOf(Object o) {
73: return triggerLazyLoading().lastIndexOf(o);
74: }
75:
76: @Override
77: public ListIterator<E> listIterator() {
78: return triggerLazyLoading().listIterator();
79: }
80:
81: @Override
82: public ListIterator<E> listIterator(int index) {
83: return triggerLazyLoading().listIterator(index);
84: }
85:
86: @Override
87: public List<E> subList(int fromIndex, int toIndex) {
88: return triggerLazyLoading().subList(fromIndex, toIndex);
89: }
90: }